
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/23/2014 16:55:30
-- Generated from EDMX file: C:\Users\Rainer\Documents\Visual Studio 2012\Projects\MIZ\MIZ\DatabaseModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [MIZ];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_LichaamsRegioMeetinstrument_LichaamsRegio]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LichaamsRegioMeetinstrument] DROP CONSTRAINT [FK_LichaamsRegioMeetinstrument_LichaamsRegio];
GO
IF OBJECT_ID(N'[dbo].[FK_LichaamsRegioMeetinstrument_Meetinstrument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LichaamsRegioMeetinstrument] DROP CONSTRAINT [FK_LichaamsRegioMeetinstrument_Meetinstrument];
GO
IF OBJECT_ID(N'[dbo].[FK_AandoeningenMeetinstrument_Aandoeningen]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AandoeningenMeetinstrument] DROP CONSTRAINT [FK_AandoeningenMeetinstrument_Aandoeningen];
GO
IF OBJECT_ID(N'[dbo].[FK_AandoeningenMeetinstrument_Meetinstrument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AandoeningenMeetinstrument] DROP CONSTRAINT [FK_AandoeningenMeetinstrument_Meetinstrument];
GO
IF OBJECT_ID(N'[dbo].[FK_FunctiesMeetinstrument_Functies]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FunctiesMeetinstrument] DROP CONSTRAINT [FK_FunctiesMeetinstrument_Functies];
GO
IF OBJECT_ID(N'[dbo].[FK_FunctiesMeetinstrument_Meetinstrument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FunctiesMeetinstrument] DROP CONSTRAINT [FK_FunctiesMeetinstrument_Meetinstrument];
GO
IF OBJECT_ID(N'[dbo].[FK_DoelgroepMeetinstrument_Doelgroep]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DoelgroepMeetinstrument] DROP CONSTRAINT [FK_DoelgroepMeetinstrument_Doelgroep];
GO
IF OBJECT_ID(N'[dbo].[FK_DoelgroepMeetinstrument_Meetinstrument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DoelgroepMeetinstrument] DROP CONSTRAINT [FK_DoelgroepMeetinstrument_Meetinstrument];
GO
IF OBJECT_ID(N'[dbo].[FK_TaalMeetinstrument_Taal]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[TaalMeetinstrument] DROP CONSTRAINT [FK_TaalMeetinstrument_Taal];
GO
IF OBJECT_ID(N'[dbo].[FK_TaalMeetinstrument_Meetinstrument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[TaalMeetinstrument] DROP CONSTRAINT [FK_TaalMeetinstrument_Meetinstrument];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[LichaamsRegioSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LichaamsRegioSet];
GO
IF OBJECT_ID(N'[dbo].[AandoeningenSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AandoeningenSet];
GO
IF OBJECT_ID(N'[dbo].[FunctiesSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FunctiesSet];
GO
IF OBJECT_ID(N'[dbo].[MeetinstrumentSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MeetinstrumentSet];
GO
IF OBJECT_ID(N'[dbo].[DoelgroepSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DoelgroepSet];
GO
IF OBJECT_ID(N'[dbo].[TaalSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TaalSet];
GO
IF OBJECT_ID(N'[dbo].[LichaamsRegioMeetinstrument]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LichaamsRegioMeetinstrument];
GO
IF OBJECT_ID(N'[dbo].[AandoeningenMeetinstrument]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AandoeningenMeetinstrument];
GO
IF OBJECT_ID(N'[dbo].[FunctiesMeetinstrument]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FunctiesMeetinstrument];
GO
IF OBJECT_ID(N'[dbo].[DoelgroepMeetinstrument]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DoelgroepMeetinstrument];
GO
IF OBJECT_ID(N'[dbo].[TaalMeetinstrument]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TaalMeetinstrument];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'LichaamsRegioSet'
CREATE TABLE [dbo].[LichaamsRegioSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Lichaams_Regio] nvarchar(max)  NOT NULL,
    [Beschrijving] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'AandoeningenSet'
CREATE TABLE [dbo].[AandoeningenSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Aandoening] nvarchar(max)  NOT NULL,
    [Beschrijving] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'FunctiesSet'
CREATE TABLE [dbo].[FunctiesSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Functie] nvarchar(max)  NOT NULL,
    [Beschrijving] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'MeetinstrumentSet'
CREATE TABLE [dbo].[MeetinstrumentSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Meet_instrument] nvarchar(max)  NOT NULL,
    [Afkorting] nvarchar(max)  NOT NULL,
    [Soort_instrument] nvarchar(max)  NOT NULL,
    [Auteurs] nvarchar(max)  NOT NULL,
    [Documenten] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DoelgroepSet'
CREATE TABLE [dbo].[DoelgroepSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Doelgroep_meetinstrument] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'TaalSet'
CREATE TABLE [dbo].[TaalSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Taal_meetinstrument] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'LichaamsRegioMeetinstrument'
CREATE TABLE [dbo].[LichaamsRegioMeetinstrument] (
    [LichaamsRegio_Id] int  NOT NULL,
    [Meetinstrument_Id] int  NOT NULL
);
GO

-- Creating table 'AandoeningenMeetinstrument'
CREATE TABLE [dbo].[AandoeningenMeetinstrument] (
    [Aandoeningen_Id] int  NOT NULL,
    [Meetinstrument_Id] int  NOT NULL
);
GO

-- Creating table 'FunctiesMeetinstrument'
CREATE TABLE [dbo].[FunctiesMeetinstrument] (
    [Functies_Id] int  NOT NULL,
    [Meetinstrument_Id] int  NOT NULL
);
GO

-- Creating table 'DoelgroepMeetinstrument'
CREATE TABLE [dbo].[DoelgroepMeetinstrument] (
    [Doelgroep_Id] int  NOT NULL,
    [Meetinstrument_Id] int  NOT NULL
);
GO

-- Creating table 'TaalMeetinstrument'
CREATE TABLE [dbo].[TaalMeetinstrument] (
    [Taal_Id] int  NOT NULL,
    [Meetinstrument_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'LichaamsRegioSet'
ALTER TABLE [dbo].[LichaamsRegioSet]
ADD CONSTRAINT [PK_LichaamsRegioSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'AandoeningenSet'
ALTER TABLE [dbo].[AandoeningenSet]
ADD CONSTRAINT [PK_AandoeningenSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'FunctiesSet'
ALTER TABLE [dbo].[FunctiesSet]
ADD CONSTRAINT [PK_FunctiesSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'MeetinstrumentSet'
ALTER TABLE [dbo].[MeetinstrumentSet]
ADD CONSTRAINT [PK_MeetinstrumentSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DoelgroepSet'
ALTER TABLE [dbo].[DoelgroepSet]
ADD CONSTRAINT [PK_DoelgroepSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'TaalSet'
ALTER TABLE [dbo].[TaalSet]
ADD CONSTRAINT [PK_TaalSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [LichaamsRegio_Id], [Meetinstrument_Id] in table 'LichaamsRegioMeetinstrument'
ALTER TABLE [dbo].[LichaamsRegioMeetinstrument]
ADD CONSTRAINT [PK_LichaamsRegioMeetinstrument]
    PRIMARY KEY NONCLUSTERED ([LichaamsRegio_Id], [Meetinstrument_Id] ASC);
GO

-- Creating primary key on [Aandoeningen_Id], [Meetinstrument_Id] in table 'AandoeningenMeetinstrument'
ALTER TABLE [dbo].[AandoeningenMeetinstrument]
ADD CONSTRAINT [PK_AandoeningenMeetinstrument]
    PRIMARY KEY NONCLUSTERED ([Aandoeningen_Id], [Meetinstrument_Id] ASC);
GO

-- Creating primary key on [Functies_Id], [Meetinstrument_Id] in table 'FunctiesMeetinstrument'
ALTER TABLE [dbo].[FunctiesMeetinstrument]
ADD CONSTRAINT [PK_FunctiesMeetinstrument]
    PRIMARY KEY NONCLUSTERED ([Functies_Id], [Meetinstrument_Id] ASC);
GO

-- Creating primary key on [Doelgroep_Id], [Meetinstrument_Id] in table 'DoelgroepMeetinstrument'
ALTER TABLE [dbo].[DoelgroepMeetinstrument]
ADD CONSTRAINT [PK_DoelgroepMeetinstrument]
    PRIMARY KEY NONCLUSTERED ([Doelgroep_Id], [Meetinstrument_Id] ASC);
GO

-- Creating primary key on [Taal_Id], [Meetinstrument_Id] in table 'TaalMeetinstrument'
ALTER TABLE [dbo].[TaalMeetinstrument]
ADD CONSTRAINT [PK_TaalMeetinstrument]
    PRIMARY KEY NONCLUSTERED ([Taal_Id], [Meetinstrument_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [LichaamsRegio_Id] in table 'LichaamsRegioMeetinstrument'
ALTER TABLE [dbo].[LichaamsRegioMeetinstrument]
ADD CONSTRAINT [FK_LichaamsRegioMeetinstrument_LichaamsRegio]
    FOREIGN KEY ([LichaamsRegio_Id])
    REFERENCES [dbo].[LichaamsRegioSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Meetinstrument_Id] in table 'LichaamsRegioMeetinstrument'
ALTER TABLE [dbo].[LichaamsRegioMeetinstrument]
ADD CONSTRAINT [FK_LichaamsRegioMeetinstrument_Meetinstrument]
    FOREIGN KEY ([Meetinstrument_Id])
    REFERENCES [dbo].[MeetinstrumentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LichaamsRegioMeetinstrument_Meetinstrument'
CREATE INDEX [IX_FK_LichaamsRegioMeetinstrument_Meetinstrument]
ON [dbo].[LichaamsRegioMeetinstrument]
    ([Meetinstrument_Id]);
GO

-- Creating foreign key on [Aandoeningen_Id] in table 'AandoeningenMeetinstrument'
ALTER TABLE [dbo].[AandoeningenMeetinstrument]
ADD CONSTRAINT [FK_AandoeningenMeetinstrument_Aandoeningen]
    FOREIGN KEY ([Aandoeningen_Id])
    REFERENCES [dbo].[AandoeningenSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Meetinstrument_Id] in table 'AandoeningenMeetinstrument'
ALTER TABLE [dbo].[AandoeningenMeetinstrument]
ADD CONSTRAINT [FK_AandoeningenMeetinstrument_Meetinstrument]
    FOREIGN KEY ([Meetinstrument_Id])
    REFERENCES [dbo].[MeetinstrumentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AandoeningenMeetinstrument_Meetinstrument'
CREATE INDEX [IX_FK_AandoeningenMeetinstrument_Meetinstrument]
ON [dbo].[AandoeningenMeetinstrument]
    ([Meetinstrument_Id]);
GO

-- Creating foreign key on [Functies_Id] in table 'FunctiesMeetinstrument'
ALTER TABLE [dbo].[FunctiesMeetinstrument]
ADD CONSTRAINT [FK_FunctiesMeetinstrument_Functies]
    FOREIGN KEY ([Functies_Id])
    REFERENCES [dbo].[FunctiesSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Meetinstrument_Id] in table 'FunctiesMeetinstrument'
ALTER TABLE [dbo].[FunctiesMeetinstrument]
ADD CONSTRAINT [FK_FunctiesMeetinstrument_Meetinstrument]
    FOREIGN KEY ([Meetinstrument_Id])
    REFERENCES [dbo].[MeetinstrumentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FunctiesMeetinstrument_Meetinstrument'
CREATE INDEX [IX_FK_FunctiesMeetinstrument_Meetinstrument]
ON [dbo].[FunctiesMeetinstrument]
    ([Meetinstrument_Id]);
GO

-- Creating foreign key on [Doelgroep_Id] in table 'DoelgroepMeetinstrument'
ALTER TABLE [dbo].[DoelgroepMeetinstrument]
ADD CONSTRAINT [FK_DoelgroepMeetinstrument_Doelgroep]
    FOREIGN KEY ([Doelgroep_Id])
    REFERENCES [dbo].[DoelgroepSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Meetinstrument_Id] in table 'DoelgroepMeetinstrument'
ALTER TABLE [dbo].[DoelgroepMeetinstrument]
ADD CONSTRAINT [FK_DoelgroepMeetinstrument_Meetinstrument]
    FOREIGN KEY ([Meetinstrument_Id])
    REFERENCES [dbo].[MeetinstrumentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DoelgroepMeetinstrument_Meetinstrument'
CREATE INDEX [IX_FK_DoelgroepMeetinstrument_Meetinstrument]
ON [dbo].[DoelgroepMeetinstrument]
    ([Meetinstrument_Id]);
GO

-- Creating foreign key on [Taal_Id] in table 'TaalMeetinstrument'
ALTER TABLE [dbo].[TaalMeetinstrument]
ADD CONSTRAINT [FK_TaalMeetinstrument_Taal]
    FOREIGN KEY ([Taal_Id])
    REFERENCES [dbo].[TaalSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Meetinstrument_Id] in table 'TaalMeetinstrument'
ALTER TABLE [dbo].[TaalMeetinstrument]
ADD CONSTRAINT [FK_TaalMeetinstrument_Meetinstrument]
    FOREIGN KEY ([Meetinstrument_Id])
    REFERENCES [dbo].[MeetinstrumentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TaalMeetinstrument_Meetinstrument'
CREATE INDEX [IX_FK_TaalMeetinstrument_Meetinstrument]
ON [dbo].[TaalMeetinstrument]
    ([Meetinstrument_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------